package com.sxfq.loansupermarket.backsystem.modular.logsf.service.impl;

import com.baomidou.mybatisplus.plugins.Page;
import com.sxfq.loansupermarket.backsystem.core.shiro.ShiroKit;
import com.sxfq.loansupermarket.backsystem.core.util.StringUtil;
import com.sxfq.loansupermarket.backsystem.modular.logsf.dao.CustomerStatusLogDao;
import com.sxfq.loansupermarket.backsystem.modular.logsf.entity.*;
import com.sxfq.loansupermarket.backsystem.modular.logsf.service.ICustomerStatusLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
@Transactional
public class CustomerStatusLogServiceImpl implements ICustomerStatusLogService {

    @Autowired
    private CustomerStatusLogDao dao;

    @Override
    public List<CustomerReservationsUpdateLogInfo> getList(Page<CustomerReservationsUpdateLogInfo> page, SearchCustomerReservationsUpdateLogInfo searchInfo) {
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("page", page);
        if (StringUtil.isNotEmpty(searchInfo.getSinglePerson())) {
            params.put("singlePerson", searchInfo.getSinglePerson());
        }
        if (StringUtil.isNotEmpty(searchInfo.getCustomerId())) {
            params.put("customerId", searchInfo.getCustomerId());
        }
        if (StringUtil.isNotEmpty(searchInfo.getCustomerName())) {
            params.put("customerName", searchInfo.getCustomerName());
        }
        if (StringUtil.isNotEmpty(searchInfo.getCustomerPhone())) {
            params.put("customerPhone", searchInfo.getCustomerPhone());
        }
        if (StringUtil.isNotEmpty(searchInfo.getLogtype())) {
            params.put("logtype", searchInfo.getLogtype());
        }
        if (StringUtil.isNotEmpty(searchInfo.getStartTime())) {
            params.put("startTime", searchInfo.getStartTime());
        }
        if (StringUtil.isNotEmpty(searchInfo.getEndTime())) {
            params.put("endTime", searchInfo.getEndTime());
        }
        params.put("startIndex", searchInfo.getStartIndex());
        params.put("limitIndex", searchInfo.getLimitIndex());
        return dao.getList(page, params);
    }

    @Override
    public List<CustomerReservationsUpdateLogInfo> numberList(Page<CustomerReservationsUpdateLogInfo> page, SearchCustomerReservationsUpdateLogInfo searchInfo) {
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("page", page);
        if (StringUtil.isNotEmpty(searchInfo.getSinglePerson())) {
            params.put("singlePerson", searchInfo.getSinglePerson());
        }
        if (StringUtil.isNotEmpty(searchInfo.getCustomerId())) {
            params.put("customerId", searchInfo.getCustomerId());
        }
        if (StringUtil.isNotEmpty(searchInfo.getCustomerName())) {
            params.put("customerName", searchInfo.getCustomerName());
        }
        if (StringUtil.isNotEmpty(searchInfo.getCustomerPhone())) {
            params.put("customerPhone", searchInfo.getCustomerPhone());
        }
        if (StringUtil.isNotEmpty(searchInfo.getLogtype())) {
            params.put("logtype", searchInfo.getLogtype());
        }
        if (StringUtil.isNotEmpty(searchInfo.getStartTime())) {
            params.put("startTime", searchInfo.getStartTime());
        }
        if (StringUtil.isNotEmpty(searchInfo.getEndTime())) {
            params.put("endTime", searchInfo.getEndTime());
        }
        params.put("startIndex", searchInfo.getStartIndex());
        params.put("limitIndex", searchInfo.getLimitIndex());
        return dao.getNumberList(page, params);
    }

    @Override
    public List<OldCustomerReservationsUpdateLogInfo> getUpdateList(Page<OldCustomerReservationsUpdateLogInfo> page, SearchOldCustomerReservationsUpdateLogInfo searchInfo) {
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("page", page);
        if (StringUtil.isNotEmpty(searchInfo.getSinglePerson())) {
            params.put("singlePerson", searchInfo.getSinglePerson());
        }
        if (StringUtil.isNotEmpty(searchInfo.getCustomerName())) {
            params.put("customerName", searchInfo.getCustomerName());
        }
        if (StringUtil.isNotEmpty(searchInfo.getCustomerPhone())) {
            params.put("customerPhone", searchInfo.getCustomerPhone());
        }
        if (StringUtil.isNotEmpty(searchInfo.getStartTime())) {
            params.put("startTime", searchInfo.getStartTime());
        }
        if (StringUtil.isNotEmpty(searchInfo.getEndTime())) {
            params.put("endTime", searchInfo.getEndTime());
        }
        params.put("startIndex", searchInfo.getStartIndex());
        params.put("limitIndex", searchInfo.getLimitIndex());
        return dao.getUpdateList(page, params);
    }

    @Override
    public List<TreatmentUnitAuditorLogInfo> getTreatmentList(Page<TreatmentUnitAuditorLogInfo> page, SearchTreatmentUnitAuditorLogInfo searchInfo) {
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("page", page);
        if (StringUtil.isNotEmpty(searchInfo.getSinglePerson())) {
            params.put("singlePerson", searchInfo.getSinglePerson());
        }
        if (StringUtil.isNotEmpty(searchInfo.getCustomerName())) {
            params.put("customerName", searchInfo.getCustomerName());
        }
        if (StringUtil.isNotEmpty(searchInfo.getCustomerPhone())) {
            params.put("customerPhone", searchInfo.getCustomerPhone());
        }
        if (StringUtil.isNotEmpty(searchInfo.getStartTime())) {
            params.put("startTime", searchInfo.getStartTime());
        }
        if (StringUtil.isNotEmpty(searchInfo.getEndTime())) {
            params.put("endTime", searchInfo.getEndTime());
        }
        params.put("startIndex", searchInfo.getStartIndex());
        params.put("limitIndex", searchInfo.getLimitIndex());
        return dao.getTreatmentList(page, params);
    }

    @Override
    public List<CaseInfoLogInfo> getCaseLogList(Page<CaseInfoLogInfo> page, SearchCaseInfoLogInfo searchInfo) {
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("page", page);
        if (StringUtil.isNotEmpty(searchInfo.getReservationsId())) {
            params.put("reservationsId", searchInfo.getReservationsId());
        }
        if (StringUtil.isNotEmpty(searchInfo.getCaseId())) {
            params.put("caseId", searchInfo.getCaseId());
        }
        if (StringUtil.isNotEmpty(searchInfo.getSinglePerson())) {
            params.put("singlePerson", searchInfo.getSinglePerson());
        }
        if (StringUtil.isNotEmpty(searchInfo.getCustomerName())) {
            params.put("customerName", searchInfo.getCustomerName());
        }
        if (StringUtil.isNotEmpty(searchInfo.getCustomerPhone())) {
            params.put("customerPhone", searchInfo.getCustomerPhone());
        }
        if (StringUtil.isNotEmpty(searchInfo.getStartTime())) {
            params.put("startTime", searchInfo.getStartTime());
        }
        if (StringUtil.isNotEmpty(searchInfo.getEndTime())) {
            params.put("endTime", searchInfo.getEndTime());
        }
        params.put("startIndex", searchInfo.getStartIndex());
        params.put("limitIndex", searchInfo.getLimitIndex());
        params.put("tableName", ShiroKit.getUser().getCustomer_info());
        return dao.getCaseLogList(page, params);
    }

    @Override
    public List<CaseInfoLogInfo> getIncoLogList(Page<CaseInfoLogInfo> page, SearchCaseInfoLogInfo searchInfo) {
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("page", page);
        if (StringUtil.isNotEmpty(searchInfo.getReservationsId())) {
            params.put("reservationsId", searchInfo.getReservationsId());
        }
        if (StringUtil.isNotEmpty(searchInfo.getIncoId())) {
            params.put("incoId", searchInfo.getIncoId());
        }
        if (StringUtil.isNotEmpty(searchInfo.getSinglePerson())) {
            params.put("singlePerson", searchInfo.getSinglePerson());
        }
        if (StringUtil.isNotEmpty(searchInfo.getCustomerName())) {
            params.put("customerName", searchInfo.getCustomerName());
        }
        if (StringUtil.isNotEmpty(searchInfo.getCustomerPhone())) {
            params.put("customerPhone", searchInfo.getCustomerPhone());
        }
        if (StringUtil.isNotEmpty(searchInfo.getStartTime())) {
            params.put("startTime", searchInfo.getStartTime());
        }
        if (StringUtil.isNotEmpty(searchInfo.getEndTime())) {
            params.put("endTime", searchInfo.getEndTime());
        }
        params.put("startIndex", searchInfo.getStartIndex());
        params.put("limitIndex", searchInfo.getLimitIndex());
        params.put("tableName", ShiroKit.getUser().getCustomer_info());
        return dao.getIncoLogList(page, params);
    }

    @Override
    public List<YellowNumberUpdateLogInfo> getYellowList(Page<YellowNumberUpdateLogInfo> page, SearchYellowNumberUpdateLogInfo searchInfo) {
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("page", page);
        if (StringUtil.isNotEmpty(searchInfo.getSinglePerson())) {
            params.put("singlePerson", searchInfo.getSinglePerson());
        }
        if (StringUtil.isNotEmpty(searchInfo.getCustomerName())) {
            params.put("customerName", searchInfo.getCustomerName());
        }
        if (StringUtil.isNotEmpty(searchInfo.getCustomerPhone())) {
            params.put("customerPhone", searchInfo.getCustomerPhone());
        }
        if (StringUtil.isNotEmpty(searchInfo.getStartTime())) {
            params.put("startTime", searchInfo.getStartTime());
        }
        if (StringUtil.isNotEmpty(searchInfo.getEndTime())) {
            params.put("endTime", searchInfo.getEndTime());
        }
        params.put("startIndex", searchInfo.getStartIndex());
        params.put("limitIndex", searchInfo.getLimitIndex());
        return dao.getYellowList(page, params);
    }

    @Override
    public List<DoctorDailyLog> getDocotrDailyLogList(Page<DoctorDailyLog> page, SearchDoctorDailyLog searchInfo) {
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("page", page);
        if (StringUtil.isNotEmpty(searchInfo.getReservationsId())) {
            params.put("reservationsId", searchInfo.getReservationsId());
        }
        params.put("startIndex", searchInfo.getStartIndex());
        params.put("limitIndex", searchInfo.getLimitIndex());
        return dao.getDailyLogList(page,params);
    }

    @Override
    public int getDailyPageCount(Page<DoctorDailyLog> page, SearchDoctorDailyLog searchInfo) {
        Map<String, Object> params = new HashMap<String, Object>();
        if (StringUtil.isNotEmpty(searchInfo.getReservationsId())) {
            params.put("reservationsId", searchInfo.getReservationsId());
        }
        params.put("page", page);
        return dao.getDailyLogCount(page, params);
    }

    @Override
    public int getQueryPagesCount(Page<CustomerReservationsUpdateLogInfo> page, SearchCustomerReservationsUpdateLogInfo searchInfo) {
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("page", page);
        if (StringUtil.isNotEmpty(searchInfo.getSinglePerson())) {
            params.put("singlePerson", searchInfo.getSinglePerson());
        }
        if (StringUtil.isNotEmpty(searchInfo.getCustomerId())) {
            params.put("customerId", searchInfo.getCustomerId());
        }
        if (StringUtil.isNotEmpty(searchInfo.getCustomerName())) {
            params.put("customerName", searchInfo.getCustomerName());
        }
        if (StringUtil.isNotEmpty(searchInfo.getCustomerPhone())) {
            params.put("customerPhone", searchInfo.getCustomerPhone());
        }
        if (StringUtil.isNotEmpty(searchInfo.getLogtype())) {
            params.put("logtype", searchInfo.getLogtype());
        }
        if (StringUtil.isNotEmpty(searchInfo.getStartTime())) {
            params.put("startTime", searchInfo.getStartTime());
        }
        if (StringUtil.isNotEmpty(searchInfo.getEndTime())) {
            params.put("endTime", searchInfo.getEndTime());
        }
        return dao.getQueryPagesCount(page, params);
    }

    @Override
    public int getQueryNumberCount(Page<CustomerReservationsUpdateLogInfo> page, SearchCustomerReservationsUpdateLogInfo searchInfo) {
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("page", page);
        if (StringUtil.isNotEmpty(searchInfo.getSinglePerson())) {
            params.put("singlePerson", searchInfo.getSinglePerson());
        }
        if (StringUtil.isNotEmpty(searchInfo.getCustomerId())) {
            params.put("customerId", searchInfo.getCustomerId());
        }
        if (StringUtil.isNotEmpty(searchInfo.getCustomerName())) {
            params.put("customerName", searchInfo.getCustomerName());
        }
        if (StringUtil.isNotEmpty(searchInfo.getCustomerPhone())) {
            params.put("customerPhone", searchInfo.getCustomerPhone());
        }
        if (StringUtil.isNotEmpty(searchInfo.getLogtype())) {
            params.put("logtype", searchInfo.getLogtype());
        }
        if (StringUtil.isNotEmpty(searchInfo.getStartTime())) {
            params.put("startTime", searchInfo.getStartTime());
        }
        if (StringUtil.isNotEmpty(searchInfo.getEndTime())) {
            params.put("endTime", searchInfo.getEndTime());
        }
        return dao.getnumberPagesCount(page, params);
    }

    @Override
    public int getQueryPagesCountt(Page<OldCustomerReservationsUpdateLogInfo> page, SearchOldCustomerReservationsUpdateLogInfo searchInfo) {
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("page", page);
        if (StringUtil.isNotEmpty(searchInfo.getSinglePerson())) {
            params.put("singlePerson", searchInfo.getSinglePerson());
        }
        if (StringUtil.isNotEmpty(searchInfo.getCustomerName())) {
            params.put("customerName", searchInfo.getCustomerName());
        }
        if (StringUtil.isNotEmpty(searchInfo.getCustomerPhone())) {
            params.put("customerPhone", searchInfo.getCustomerPhone());
        }
        if (StringUtil.isNotEmpty(searchInfo.getStartTime())) {
            params.put("startTime", searchInfo.getStartTime());
        }
        if (StringUtil.isNotEmpty(searchInfo.getEndTime())) {
            params.put("endTime", searchInfo.getEndTime());
        }
        return dao.getQueryPagesCountt(page, params);
    }

    @Override
    public int getTreatmentCount(Page<TreatmentUnitAuditorLogInfo> page, SearchTreatmentUnitAuditorLogInfo searchInfo) {
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("page", page);
        if (StringUtil.isNotEmpty(searchInfo.getSinglePerson())) {
            params.put("singlePerson", searchInfo.getSinglePerson());
        }
        if (StringUtil.isNotEmpty(searchInfo.getCustomerName())) {
            params.put("customerName", searchInfo.getCustomerName());
        }
        if (StringUtil.isNotEmpty(searchInfo.getCustomerPhone())) {
            params.put("customerPhone", searchInfo.getCustomerPhone());
        }
        if (StringUtil.isNotEmpty(searchInfo.getStartTime())) {
            params.put("startTime", searchInfo.getStartTime());
        }
        if (StringUtil.isNotEmpty(searchInfo.getEndTime())) {
            params.put("endTime", searchInfo.getEndTime());
        }
        return dao.getTreatmentCount(page, params);
    }

    @Override
    public int getCaseInfoLogCount(Page<CaseInfoLogInfo> page, SearchCaseInfoLogInfo searchInfo) {
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("page", page);
        if (StringUtil.isNotEmpty(searchInfo.getReservationsId())) {
            params.put("reservationsId", searchInfo.getReservationsId());
        }
        if (StringUtil.isNotEmpty(searchInfo.getCaseId())) {
            params.put("caseId", searchInfo.getCaseId());
        }
        if (StringUtil.isNotEmpty(searchInfo.getSinglePerson())) {
            params.put("singlePerson", searchInfo.getSinglePerson());
        }
        if (StringUtil.isNotEmpty(searchInfo.getCustomerName())) {
            params.put("customerName", searchInfo.getCustomerName());
        }
        if (StringUtil.isNotEmpty(searchInfo.getCustomerPhone())) {
            params.put("customerPhone", searchInfo.getCustomerPhone());
        }
        if (StringUtil.isNotEmpty(searchInfo.getStartTime())) {
            params.put("startTime", searchInfo.getStartTime());
        }
        if (StringUtil.isNotEmpty(searchInfo.getEndTime())) {
            params.put("endTime", searchInfo.getEndTime());
        }
        params.put("tableName", ShiroKit.getUser().getCustomer_info());
        return dao.getCaseInfoLogCount(page, params);
    }

    @Override
    public int getIncoInfoLogCount(Page<CaseInfoLogInfo> page, SearchCaseInfoLogInfo searchInfo) {
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("page", page);
        if (StringUtil.isNotEmpty(searchInfo.getReservationsId())) {
            params.put("reservationsId", searchInfo.getReservationsId());
        }
        if (StringUtil.isNotEmpty(searchInfo.getIncoId())) {
            params.put("incoId", searchInfo.getIncoId());
        }
        if (StringUtil.isNotEmpty(searchInfo.getSinglePerson())) {
            params.put("singlePerson", searchInfo.getSinglePerson());
        }
        if (StringUtil.isNotEmpty(searchInfo.getCustomerName())) {
            params.put("customerName", searchInfo.getCustomerName());
        }
        if (StringUtil.isNotEmpty(searchInfo.getCustomerPhone())) {
            params.put("customerPhone", searchInfo.getCustomerPhone());
        }
        if (StringUtil.isNotEmpty(searchInfo.getStartTime())) {
            params.put("startTime", searchInfo.getStartTime());
        }
        if (StringUtil.isNotEmpty(searchInfo.getEndTime())) {
            params.put("endTime", searchInfo.getEndTime());
        }
        params.put("tableName", ShiroKit.getUser().getCustomer_info());
        return dao.getIncoInfoLogCount(page, params);
    }

    @Override
    public int getQueryPagesCounts(Page<YellowNumberUpdateLogInfo> page, SearchYellowNumberUpdateLogInfo searchInfo) {
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("page", page);
        if (StringUtil.isNotEmpty(searchInfo.getSinglePerson())) {
            params.put("singlePerson", searchInfo.getSinglePerson());
        }
        if (StringUtil.isNotEmpty(searchInfo.getCustomerName())) {
            params.put("customerName", searchInfo.getCustomerName());
        }
        if (StringUtil.isNotEmpty(searchInfo.getCustomerPhone())) {
            params.put("customerPhone", searchInfo.getCustomerPhone());
        }
        if (StringUtil.isNotEmpty(searchInfo.getStartTime())) {
            params.put("startTime", searchInfo.getStartTime());
        }
        if (StringUtil.isNotEmpty(searchInfo.getEndTime())) {
            params.put("endTime", searchInfo.getEndTime());
        }
        return dao.getQueryPagesCounts(page, params);
    }
}